﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.IO;
using DevExpress.XtraBars;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.Utils;

namespace ProgramMain.Framework
{
    public partial class BaseComboBoxViewCtl : ProgramMain.Framework.BaseListCtl
    {
        public BaseComboBoxViewCtl()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Заголовок ComboBox
        /// </summary>
        public string LookupCaption
        {
            get { return layoutControl1.Text; }
            set
            {
                layoutControl1.Text = value;
            }
        }

        private void lookupControl1_Properties_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            EditorButton btn = e.Button;
            try
            {
                string action = btn.Tag.ToString();

                if (action == "add")
                {
                    Action_Add(sender, EventArgs.Empty);
                }
                else if (action == "edit")
                {
                    Action_Edit(sender, EventArgs.Empty);
                }
                else if (action == "delete")
                {
                    Action_Edit(sender, EventArgs.Empty);
                } 
                else if (action == "refresh")
                {
                    Action_Refresh(sender, EventArgs.Empty);
                }

            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}
